package com.ssy.lingxi.settle.accounts.model.constant;

import com.ssy.lingxi.common.language.LanguageHolder;
import com.ssy.lingxi.dto.model.constant.SettlementHelpEnum;

import java.util.Arrays;

/**
 * 对账单状态
 * @author Saske
 * @date 2021/12/2
 * @version 2.0.0
 */
public enum ReconciliationOuterStatusEnum {

    /**
     * 待提交对账单
     */
    WAIT_SUBMIT(1,"", 1),
    /**
     * 提交对账单
     */
    TO_SUBMIT(2, "提交对账单",1),
    /**
     * 取消提交对账单
     */
    to_Cancel(3, "提交对账单",1),
    /**
     * 确认对账单
     */
    TO_CONFIRM(4, "确认对账单",2),
    /**
     * 请款
     */
    APPLY(5, "请款", 3),

    ;

    private final Integer code;
    private final String message;
    private final Integer step;

    ReconciliationOuterStatusEnum(Integer code, String message, Integer step) {
        this.code = code;
        this.message = message;
        this.step = step;
    }

    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return LanguageHolder.getName(this.getDeclaringClass(), this.getCode());
    }

    public Integer getStep() {
        return step;
    }

    /**
     * 根据状态枚举值获得状态名称
     * @param code 外部状态枚举值
     * @return 外部状态名称
     */
    public static String getNameByCode(Integer code) {
        ReconciliationOuterStatusEnum statusEnum = Arrays.stream(ReconciliationOuterStatusEnum.values()).filter(e -> e.getCode().equals(code)).findFirst().orElse(null);
        return statusEnum == null ? SettlementHelpEnum.UNKNOWN.getMessage() : statusEnum.getMessage();
    }

    public static String getNameByStep(Integer step) {
        ReconciliationOuterStatusEnum statusEnum = Arrays.stream(ReconciliationOuterStatusEnum.values()).filter(e -> e.getStep().equals(step)).findFirst().orElse(null);
        return statusEnum == null ? SettlementHelpEnum.UNKNOWN.getMessage() : statusEnum.getMessage();
    }

}
